package com.nc.user.model.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@Lazy
public class FrmRequestLog {
    @Id
    @GeneratedValue(generator = "NumberIdProduce")
    @GenericGenerator(name = "NumberIdProduce", strategy = "com.plug.idProduce.NumberIdProduce")
    private String id;

    @Lob
    @Column
    private String acceptJson;

    @Lob
    @Column
    private String backJson;

    @Lob
    @Column
    private String headers;

    @Column
    private String apiName;

    @CreatedDate
    @Column
    private Date createTime;

    @Column
    private String ip;

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum Status {
        NO("失败"),
        YES("成功");
        Status(String display) {
            this.display = display;
        }
        private String display;

        public String getDisplay() {
            return display;
        }

        public void setDisplay(String display) {
            this.display = display;
        }
    }

    @Enumerated(EnumType.STRING)
    @Column
    private Status status;

    @ManyToOne
    @JoinColumn(name = "authorId")
    private FrmUsers author;
}
